{% extends 'nav.html' %}
{% block title %}Case List{% endblock %}
{% block slideshow %}
    <br/><br/><br/>
    <form class="form-inline" role="form" action="" method="GET">
    {% if caselist %}
        <div class="panel panel-default">
    <div class="panel-heading">
          <div class="form-group">
            <select name="projectid" class="form-control">
              <option value="">所属项目</option>
              {% for i in caselist %}
                 <option value="{{ i.projectid }}" {% if request.GET.projectid  == i.projectid %}selected{% endif %}>{{ i.projectid }}</option>
              {% endfor %}
            </select>
          </div>
          <div class="form-group">
            <select name="moduleid" class="form-control">
              <option value="">模 块</option>
              {% for i in caselist %}
                    <option value="{{ i.moduleid }}" {% if request.GET.modulename  == i.moduleid %}selected{% endif %}>{{ i.moduleid }}</option>
                {% endfor %}
            </select>
          </div>
          <div class="form-group">
            <select name="casestatus" class="form-control">
              <option value="">状态</option>
                 <option value="True" >启用</option>
                 <option value="False" >禁用</option>
            </select>
          </div>
          <div class="form-group">
          <input type="input" name="keyword" class="form-control" placeholder="Please input Keyword" value="{{ request.GET.keyword }}">
          </div>
          <button type="submit" class="btn btn-primary">Search</button>
        <div align="right" class="form-group"><a href="/case/add/" class="btn btn-primary">Add Case</a></div>
      </div>
        <table class="table table-striped table-bordered table-hover table-condensed">
        <thead>
          <tr>
              <th>Case ID</th>
              <th>Module Name</th>
              <th>Case Descr</th>
              <th>Case Status</th>
              <th>Create At</th>
              <th>Create Time</th>
              <th>UpdateAt</th>
              <th>Update Time</th>
          <th></th>
          </tr>
        </thead>
        <tbody>
          {% for case in caselist %}
            <tr>
                <td>{{ case.id }}</td>
                <td>{{ case.moduleid.name }}</td>
                <td><a href="{% url 'caseview' case.id %}"/> {{ case.casedesc }}</td>
                <td>{{ case.isenabled }}</td>
                <td>{{ case.createat }}</td>
                <td>{{ case.createtime|date:'Y-m-d H:i:s' }}</td>
                <td>{{ case.createat }}</td>
                <td>{{ case.updatetime|date:'Y-m-d H:i:s' }}</td>
                <th>
                    <a href="{% url 'caseupdate' case.id %}" class="btn btn-primary" role="button">Edit</a>
                    <a href="{% url 'casedel' case.id %}" class="btn btn-primary" role="button" onclick="return confirm('Are you Sure Deleted.')">Delete</a>
                </th>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
        {% if is_paginated %}
        <div class="panel-default">
        <ul class="pagination">
          <li><a href="{{ request.path }}?page=1">«</a></li>
          {% if page_obj.has_previous %}
            <li><a href="{{ request.path }}?&page={{ page_obj.previous_page_number }}">上一页</a></li>
          {% else %}
            <li class="previous disabled"><a>上一页</a></li>
          {% endif %}
          {% for i in page_obj.paginator.page_range %}
            <li {% if page_obj.number == i %}class="active"{% endif %}><a href="{{ request.path }}?page={{ i }}">{{ i }}</a></li>
          {% endfor %}
          {% if page_obj.has_next %}
            <li><a href="{{ request.path }}?page={{ page_obj.next_page_number }}">下一页</a></li>
          {% else %}
            <li class="previous disabled"><a>下一页</a></li>
          {% endif %}
          <li><a href="{{ request.path }}?page={{ page_obj.paginator.num_pages }}">»</a></li>
            <li><span>This is {{ page_obj.number }}</span></li>
        </ul>
    </div>
        {% endif %}
    {% else %}
        <p> No msg!!!</p>
    {% endif %}
  </form>
{% endblock %}
